﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangMayTinh.DataAccessLayer;
using CuaHangMayTinh.BusinessEntities;
using CuaHangMayTinh.Utilities;
using System.Data;

namespace CuaHangMayTinh.BusinessLogicLayer
{
    public class ChiTietBanHangManager
    {
        private static ChiTietBanHangDA adapter = null;

        static ChiTietBanHangManager()
        {
            if (adapter == null)
                adapter = new ChiTietBanHangDA();
        }

        /// <summary>
        /// Hàm thêm 1 chi tiết bán hàng
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static int Insert(ChiTietBanHangEntity entity)
        {
            try
            {
                return adapter.Insert(entity);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return 0;
            }
        }

        /// <summary>
        /// Hàm cập nhật 1 chi tiết bán hàng
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static bool UpDate_ID(ChiTietBanHangEntity entity)
        {
            try
            {
                return adapter.UpDate_ID(entity);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
                return false;
            }
        }
    }
}
